!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define("rb_wixui.thunderbolt[ComboBoxInputListModal]",["react"],t):"object"==typeof exports?exports["rb_wixui.thunderbolt[ComboBoxInputListModal]"]=t(require("react")):e["rb_wixui.thunderbolt[ComboBoxInputListModal]"]=t(e.React)}("undefined"!=typeof self?self:this,(function(e){return function(){var t={5329:function(t){"use strict";t.exports=e},448:function(e){function t(){return e.exports=t=Object.assign?Object.assign.bind():function(e){for(var t=1;t{t.keyCode===e&&(t.preventDefault(),t.stopPropagation(),t.currentTarget.click())}}v(32),v(l),v(u);const b=()=>{},x="designable_list",m="designable_list_option",g=function(e,t){const n=e.offsetTop,o=n+e.getBoundingClientRect().height,r=t.scrollTop,i=r+t.offsetHeight;return n>=r&&o<=i};var h="sTe93V",y="DYoNOT",E="_Gybpq",O="CEK3nk",C="P6sHUt";const M={ComboBoxInputListModal:{component:e=>{const{id:n,value:o,options:r,hoveredOptionIndex:l,className:u,setDesignableListElem:v=b,isComboBoxSelectionFeedbackExperimentOpen:M,setHoveredOptionIndex:_=b,onSelectedOptionChange:I=b}=e,k="menuitem",T=e.filteredOptions||e.options,[j,R]=s.useState(null),[S,w]=s.useState(!1),B=s.useRef(null),L=s.useRef(null),P=s.useRef(null),D=s.useRef(null),[H,N]=s.useState({"--optionLineHeight":"1.3em"}),A=function(e,t){void 0===t&&(t=null);const n=(0,s.useRef)(t);return(0,s.useEffect)((()=>{n.current=e}),[e]),n.current}(l)||0,q=s.useCallback((()=>{const e=L.current;if(e){const t=e.getBoundingClientRect();N({"--optionLineHeight":0===t.height?"1.3em":t.height+"px"})}}),[L]);(e=>{let{callback:t,ref:n,elem:o}=e;(0,s.useEffect)((()=>{const e=new ResizeObserver(t);return null!=n&&n.current&&e.observe(n.current),o&&e.observe(o),()=>{e.disconnect()}}),[n,o,t])})({ref:L,callback:q});const K=s.useCallback((function(e,t){void 0===t&&(t=!0),I(null==e?void 0:e.value,t)}),[I]);s.useEffect((()=>{const e=P.current||B.current;e&&j&&(j.scrollTop=e.offsetTop)}),[j,H]);const U=s.useMemo((()=>T.findIndex((e=>e.value===o))),[T,o]);s.useEffect((()=>{const e=D.current||P.current||B.current;S||-1===l||(l>=A?(e=>{let{optionEl:t,listEl:n}=e;t&&n&&!g(t,n)&&(n.scrollTop=t.offsetTop-n.offsetHeight+t.getBoundingClientRect().height)})({optionEl:e,listEl:j}):(e=>{let{optionEl:t,listEl:n,hoveredOptionIndex:o}=e;t&&n&&!g(t,n)&&(n.scrollTop=t.getBoundingClientRect().height*o)})({optionEl:e,listEl:j,hoveredOptionIndex:l}))}),[l,A,j,S]);const z=s.useMemo((()=>r.findIndex((e=>!!e.text))),[r]),[F,G]=s.useState(-1===l?0:l),V=s.useCallback((e=>{const t=e=>{G((t=>{const n=Math.max(0,Math.min(t+e,r.length-1));_(n);const o=r[n];return K(o,!1),n}))},n=()=>{if(-1!==F){const e=r[F];K(e)}},o={[d]:()=>t(-1),[f]:()=>t(1),[c]:()=>n(),[a]:()=>n(),[p]:()=>K(r[U])};var i;M&&(e.preventDefault(),null==(i=o[e.key])||i.call(o))}),[K,F,r,_,U,M]);s.useEffect((()=>{if(!M)return;const e=document.getElementById(k+"-"+l);e&&-1!==l&&e.focus()}),[l,M]);const Y=e=>e===z?L:void 0;return s.createElement("div",t()({id:(J=n,"listModal_"+J)},(e=>Object.entries(e).reduce(((e,[t,n])=>(t.includes("data-")&&(e[t]=n),e)),{}))(e),{className:i(y,u),tabIndex:-1}),s.createElement("div",{ref:e=>{v(e),R(e)},"data-testid":x,className:E,role:"listbox",style:{...H}},r.map(((e,t)=>{return s.createElement("div",{onKeyDown:V,key:t,id:k+"-"+t,ref:(n=t,n===U?P:0===n?B:n===l?D:void 0),className:i(O,{[h]:l===t}),onClick:()=>K(e),onMouseEnter:()=>(_(t),void w(!0)),onMouseLeave:()=>(_(-1),void w(!1)),"data-testid":m,role:"option","aria-selected":e.value===o,style:e.style,tabIndex:l===t?0:-1},s.createElement("div",{ref:Y(t),className:C},e.text));var n}))));var J}}}}(),r}()})); //# sourceMappingURL=https://static.parastorage.com/services/editor-elements-library/dist/thunderbolt/rb_wixui.thunderbolt[ComboBoxInputListModal].ffbd163c.bundle.min.js.map